<?php
/**
 * File Name: MemberController.php
 *
 * Author: zl
 * Qq: 178417451
 * createTime 16/6/30 上午10:47
 */

namespace App\Http\Controllers\Admin;

use App\Models\Member;
use App\Models\Setting;

class MemberController extends BaseController
{
    public function __construct(Setting $setting, Member $member)
    {
        parent::__construct();
        $this->setting = $setting;
        $this->member = $member;
    }

    /**
     * 会员列表
     */
    public function getIndex()
    {
        $keyword = request('keyword', '');
        $where = [];
        if ($keyword) {
            if (is_numeric($keyword)) {
                $where['id'] = $keyword;
            } else {
                $where['wxname'] = ['like', '%' . $keyword . '%'];
            }
        }

        $order['id'] = 'desc';
        $rows = $this->member->getList($where, '*', $order, 5);
        if ($rows) {
            $rows = $rows->toArray();
            $rows['pageNoList'] = getPageNoList($rows['last_page'], request('page', 1), 10);
        }
        return view('admin.member.index', compact('rows', 'keyword'));
    }

    public function getEdit()
    {

    }
}
